package com.learn.springboot.config;

import org.aspectj.lang.ProceedingJoinPoint;
import org.aspectj.lang.annotation.AfterThrowing;
import org.aspectj.lang.annotation.Around;
import org.aspectj.lang.annotation.Aspect;
import org.aspectj.lang.annotation.Before;
import org.aspectj.lang.annotation.Pointcut;
import org.springframework.stereotype.Component;


@Component
@Aspect
public class LogAspect {

    @Around(value ="pointcut()"
    )
    private Object anyPublicOperation(ProceedingJoinPoint proceedingJoinPoint ) {
        String errMsg="";
        try {
            return proceedingJoinPoint.proceed();
        } catch (Throwable throwable) {

            System.out.println(throwable.getLocalizedMessage());
            return throwable.getLocalizedMessage();
        }

    }

    @Pointcut("execution(public * com.learn.springboot.controller.TestController.*(..))")
    public void pointcut(){

    }
}
